#ifndef TICTACTOEWIDGET_H
#define TICTACTOEWIDGET_H

#include <QPushButton>
#include <QWidget>
#include <QSet>
#include <vector>

class TicTacToeWidget : public QWidget
{
    Q_OBJECT
public:
    enum class Player{
      Invalid,Player1,Player2,Draw
    };
    Q_ENUM(Player)
public:
    TicTacToeWidget(QWidget *parent = nullptr);
    ~TicTacToeWidget();
    void InitGame();
    Player GetCurrentPlayer() const;
    void SetCurrentPlayer(const Player& p_player);
    Player CheckWinCondition();
signals:    //发送
    void CurrentPlayerChanged(Player);
    void GameOver(Player);
private slots:  //接收
    void HandleButtonClick(int index);
private:
    QVector<QPushButton*> m_broad;
    Player m_currentPlayer;
    QSet<int> A;
    QSet<int> B;
private:
    QVector<QVector<int>> m_winCondition;
};

#endif // TICTACTOEWIDGET_H
